import time
import argparse
import sys
sys.path.append('.')
from util.PATH import PATH as PATH
from baseline.basic.LDA_SVM import svm_main as SVM_main
from baseline.basic.LDA_KL import main as KL_main
from baseline.basic.DERTOM import main as DERTOM_main
from src.data_helper import DataHelper as DataHelper

if __name__ == '__main__':

	parser = argparse.ArgumentParser(description='helloworld')
	parser.add_argument('dataset', help='数据集名字')
	parser.add_argument('model', help='模型名字，如SVM、KL、DERTOM')

	args = parser.parse_args()

	PATH = PATH(args.dataset)
	data_helper = DataHelper(PATH)
	bug_msg_all, _ = data_helper.get_msg_all()

	vocabulary = data_helper.create_vocabulary()
	developers_list = data_helper.create_developers_list()
	time_windows = data_helper.read_dataset_by_category()   # 存放的是id

	# names = ['Eclipse', 'GCC', 'Mozilla', 'Netbeans', 'OpenOffice']
	# path = PATH.root
	# name = PATH.root.split('/')[-2]

	# T = 300             # 这俩参数写在这儿是为了使"程序入口"这个概念更加名副其实, 方便调节
	# n_iteration = 200
	# parser = argparse.ArgumentParser()
	# parser.add_argument('index', help='指定数据集的索引')
	# args = parser.parse_args()
	# index = int(args.index)

	start_time = time.clock()
	print('数据集:{}'.format(args.dataset))
	if args.model == 'SVM':

		SVM_main(args.dataset, time_windows[0], time_windows[1] + time_windows[2], data_helper)
	elif args.model == 'KL':
		KL_main(args.dataset, time_windows[0], time_windows[1] + time_windows[2], data_helper)
	elif args.model == 'DERTOM':
		DERTOM_main(args.dataset, time_windows[0], time_windows[1] + time_windows[2], data_helper)
	print('花费时间: {}'.format(time.clock() - start_time))